ComparableValidationAttribute
Ecng.ComponentModel
Provides a base class for validation attributes that compare values of a struct type.
继承自: ValidationAttribute
实现: IValidator
属性
DisableNullCheck
public bool DisableNullCheck { get; set; }
value = comparableValidationAttribute.DisableNullCheck
comparableValidationAttribute.DisableNullCheck = value
Gets or sets a value indicating whether to disable the null check. When set to true, null values bypass validation.
方法
IsValid
public override bool IsValid(object value)
result = comparableValidationAttribute.IsValid(value)
Validates the specified value by converting it and applying the custom validation.
- value
- The value to validate.
返回值: True if the value is valid; otherwise, false.
Validate
protected abstract bool Validate(T? value, bool disableNullCheck)
result = comparableValidationAttribute.Validate(value, disableNullCheck)
Validates the given nullable value using a custom rule.
- value
- The nullable value to validate.
- disableNullCheck
- A flag indicating whether null check should be disabled.
返回值: True if the value passes the validation rule; otherwise, false.